<template>
  <el-dropdown trigger="click" @command="changeType">
    <!-- 这里必须加一个div -->
    <div>
      <svg-icon style="color: #fff; font-size: 20px" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale==='zh'" command="zh">中文</el-dropdown-item>
      <el-dropdown-item :disabled="$i18n.locale==='en'" command="en">en</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>
<script>
import Cookies from 'js-cookie'
export default {
  methods: {
    changeType(type) {
      // 将选择语言包保存在cookie中
      Cookies.set('language', type)
      // 响应式更改语言包类型
      this.$i18n.locale = type
      this.$message.success('切换多语言成功')
    }
  }
}
</script>
